package data;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Data {
	
	public static void main(String[] args)
	{
		final String sqlUrl = "jdbc:mysql://localhost:3306/user";
		final String sqlUser = "root";
		final String sqlPasswd = "";
		final String sqlDriver = "com.mysql.jdbc.Driver";
	    Connection conn = null; 
	    
	    try
	    {
	    	Class.forName(sqlDriver);
	    	conn = DriverManager.getConnection(sqlUrl, sqlUser, sqlPasswd);
	    	if(conn.isValid(5000)){
	    			    	
	    		final String QUERY = "SELECT * FROM authors";
	    		System.out.println(QUERY);
	    	}
	    }
	    catch(ClassNotFoundException ex)
	    {
	    	System.out.println("Ukendt driver!");
	    	ex.printStackTrace();
	    }
	    catch(SQLException ex)
	    {
	    	System.out.println("Kunne ikke forbinde til databasen");
	    	ex.printStackTrace();
	    }
	    
	}

	

}
